<template>
  <div
        class="video-player-box"
        v-if="show && video !== null"
        >
        <i class="el-icon-close player-close" @click="closeVideoPlayer"></i>
        <div class="player-mask"/>
            <video
            class="video-player"
            :src="`${video.uri}?${new Date().getTime()}`"
            controls
            preload
            :cache="false"
        />
    </div>
</template>

<script>
export default {
    props: {
        video: {
            type: Object,
            default: () => ({})
        },
        show: {
            type: Boolean,
            default: false,
        },
    },
    data() {
        return {

        };
    },
    methods: {
        closeVideoPlayer() {
            this.$emit('close')
        }
    }
}
</script>

<style lang="less" scoped>
.video-player-box {
    position: fixed;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    z-index: 100;
    .player-mask {
        background: rgba(77, 77, 77, 0.3);
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
    }
    .player-close {
        position: absolute;
        right: 12px;
        top: 12px;
        font-size: 32px;
        color: #FFF;
        z-index: 101;
        font-weight: bold;
    }
    .video-player {
        position: fixed;
        width: 512px;
        left: 0;
        right: 0;
        top: 0;
        bottom: 0;
        margin: auto;
    }
}
</style>